package com.share.auth.controller;

import com.share.auth.service.H5LoginService;
import com.share.common.core.domain.R;
import com.share.common.security.service.TokenService;
import com.share.system.api.model.LoginUser;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ZhouShuang
 * @version 17
 * @Title
 * @date 2025/10/18 上午10:30
 */
@RestController
@RequiredArgsConstructor
public class H5LoginController {

    private final H5LoginService h5LoginService;
    private final TokenService tokenService;

    @GetMapping("/h5/login/{code}")
    public R<?> login(@PathVariable String code){
        //用户登录
        LoginUser loginUser = h5LoginService.login(code);

        //获取登录登录的token
        return R.ok(tokenService.createToken(loginUser));
    }

}
